package com.jianbing.util;

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.Map;

/**
 * Created by LFL on 2017/4/19
 */
public class ParamOperation {

    //        String param = ParamOperation.ParamToString(map);

    public static String ParamToString(Map<String, String> map) {
        String param = "";
        String nex = "";
        try {
            for (Map.Entry<String, String> entry : map.entrySet()) {
                String key = entry.getKey();
                String value = entry.getValue();
                if (!value.isEmpty()) {
                    map.put(key, URLEncoder.encode(value, "utf-8"));
                    param += nex + key + "=" + entry.getValue();
                    nex = "&";
                }
            }
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        return param;
    }
}
